package com.whfc.ms.api.uni.controller;

import com.whfc.common.base.BaseController;
import com.whfc.common.result.PageData;
import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.common.util.SessionAttr;
import com.whfc.fuum.entity.SysUser;
import com.whfc.ms.api.uni.service.MsCarWashDataService;
import com.whfc.uni.entity.CarWashData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/ms/api/carWashData")
public class CarWashDataController extends BaseController {

    @Autowired
    private MsCarWashDataService msCarWashDataService;

    @GetMapping(value = "/list", params = {"pageNum", "pageSize"})
    public Result deviceList(@SessionAttribute(SessionAttr.MS_USER) SysUser user,
                             @RequestParam("pageNum") Integer pageNum,
                             @RequestParam("pageSize") Integer pageSize,
                             @RequestParam(value = "deviceId", required = false) Integer deviceId,
                             @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam(value = "startTime", required = false) Date startTime,
                             @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam(value = "endTime", required = false) Date endTime
                             ) {
        logger.info("获取车辆冲洗数据分页：loginer:{},pageNum:{},pageSize:{},deviceId:{}",
                user.getUsername(), pageNum, pageSize,deviceId);
        PageData<CarWashData> pageData = msCarWashDataService.listPage(pageNum, pageSize,deviceId,startTime,endTime);
        return ResultUtil.success(pageData);
    }
}
